package com.pc.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pc.entity.Notice;
import com.pc.mapper.NoticeMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author 李林雨
 * @createTime 2023/12/27 20:55
 * @description
 */
@Service
public class NoticeService {

    @Resource
    private NoticeMapper noticeMapper;

    //得到当前的公告

    public Notice getNotice(){
        QueryWrapper<Notice> wrapper = new QueryWrapper<>();
        List<Notice> notices = noticeMapper.selectList(wrapper);
        return noticeMapper.selectById(notices.size());
    }

    public Boolean insertNotice(Notice notice){
        Date date = new Date();
        String s = date.toString();
        notice.setCreatetime(s);
        int insert = noticeMapper.insert(notice);
        return insert!=0;
    }
}
